import Auth from './Auth'
import Confirmation from './Confirmation'
import PasswordEdit from './PasswordEdit'
import ResetPassword from './ResetPassword'
import { frontendURL } from '../../helper/URLHelper'

const Signup = () => import('./Signup')

export default {
  routes: [
    {
      path: frontendURL('auth/signup'),
      name: 'auth_signup',
      component: Signup,
      meta: { requireSignupEnabled: true },
    },
    {
      path: frontendURL('auth'),
      name: 'auth',
      component: Auth,
      children: [
        {
          path: 'confirmation',
          name: 'auth_confirmation',
          component: Confirmation,
          props: route => ({
            config: route.query.config,
            confirmationToken: route.query.confirmationToken,
            redirectUrl: route.query.route_url,
            tenantId: route.query.tenantId,
            userId: route.query.userId,
          }),
        },
        {
          path: 'password/edit',
          name: 'auth_password_edit',
          component: PasswordEdit,
          props: route => ({
            config: route.query.config,
            tenantId: route.query.tenantId,
            userId: route.query.userId,
            resetPasswordToken: route.query.resetPasswordToken,
            redirectUrl: route.query.route_url,
          }),
        },
        {
          path: 'reset/password',
          name: 'auth_reset_password',
          component: ResetPassword,
        },
      ],
    },
  ],
}
